package com.service.zy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.dao.zy.PurchaseDetailDao;
import com.entity.PurchaseDetail;
import com.service.ServiceException;

@Service
@Transactional(rollbackFor=ServiceException.class)
public class PurchaseDetailService {
	@Autowired
	private PurchaseDetailDao purchasedetailDao;
	
	/**
	 * 添加一个采购详情单
	 * @param purchaseDetail
	 * @throws ServiceException
	 */
	public void add(PurchaseDetail purchaseDetail) throws ServiceException {
		try {
			purchasedetailDao.save(purchaseDetail);
		}catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}
	
	/**
	 * 查询一个采购详情单
	 * @param id
	 * @return
	 * @throws ServiceException
	 */
	public PurchaseDetail findDetail(Long id) throws ServiceException {
		try {
			return purchasedetailDao.findOne(id);
		}catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}
	
	/**
	 * 删除一个采购详情单
	 * @param id
	 * @throws ServiceException
	 */
	public void delOne(Long id) throws ServiceException {
		try {
			purchasedetailDao.delete(id);
		}catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}
}
